<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import = "java.util.List" %>
<%@ page import ="java.util.ArrayList"%>
<%@ page import ="javax.script.Invocable"%>
<%@ page import ="javax.script.ScriptEngine"%>
<%@ page import ="javax.script.ScriptEngineManager"%>
<%@ page import ="java.io.BufferedReader"%>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>System Portal</title>
	<link rel="stylesheet" type="text/css" href="css/stylev2.css"/>
	
	<style type="text/css">
		a {
	      text-decoration:none;
	   }
	</style>
	
	<script>
		$(document).ready(function(){
			
			 $("td").hover(
				function() {
			      $(this).css('background-color', '#ffffffff');
			      $(this).css('color', '#000000');
			    }, 
			    function() {
			      $(this).css('background-color', 'none');
			      $(this).css('color', 'black'); // or whatever your original color was
			    });		
		});
	///////////////////////////////////////////////////
	
		function link_system(id){
				
			if(id=="student_system")
			{
				document.location.href="student_home.jsp";
			}else if(id=="enroll_system"){
				document.location.href="enroll_home.jsp";
			}else if(id=="curriculum_system"){
				document.location.href="curriculum_home.jsp";
			}
		}
	</script>	
	<style type="text/css">
			#main-content-act {
				background:rgba(0,0,0,0.2);
				padding-left: 50px;
				padding-top: 30px;
				padding-right: 10px;
			}
			
			td:hover {
			  background-color: rgba(39,39,91, 0.5);
			  cursor: pointer;
			
			}
			
			table, th, td
			{
			  border: 0;
			}
			table
			{
			  border-collapse:collapse;
			}
	
	</style>
</head>
<body>

<%
	String strUser = String.valueOf(session.getAttribute("sUser"));
	HttpSession htp_session = request.getSession();
			
	if (htp_session == null || htp_session.getAttribute("sUser") == null) {
	    // Forward the control to login.jsp if authentication fails or session expires
	    request.getRequestDispatcher("/login.jsp").forward(request,
	        response);
	}
	
	if("admin".equals(htp_session.getAttribute("sUser"))){%>
	<script>alert("This user dont have PERMISSION to access this zone.");</script>
	<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=admin_home.jsp"> 	
	<%}
	
	////////// try to printout persion ///////////
	
	String name = String.valueOf(session.getAttribute("name"));
	String surname = String.valueOf(session.getAttribute("surname"));
	String department_id = String.valueOf(session.getAttribute("department_id"));
			
	System.out.println("name : " + name);///////////////////////////////
	System.out.println("surname: "+surname);
		
	System.out.println("department_id : " + department_id);/////////////////////////
	
	
	
	System.out.println("student C : " + String.valueOf(session.getAttribute("student_create")));/////////////////////////
	System.out.println("student U : " + String.valueOf(session.getAttribute("student_update")));/////////////////////////
	System.out.println("student R : " + String.valueOf(session.getAttribute("student_read")));/////////////////////////
	System.out.println("student D : " + String.valueOf(session.getAttribute("student_delete")));/////////////////////////
	System.out.println("curriculum C : " + String.valueOf(session.getAttribute("curriculum_create")));/////////////////////////
	System.out.println("curriculum U : " + String.valueOf(session.getAttribute("curriculum_update")));/////////////////////////
	System.out.println("curriculum R : " + String.valueOf(session.getAttribute("curriculum_read")));/////////////////////////
	System.out.println("curriculum D : " + String.valueOf(session.getAttribute("curriculum_delete")));/////////////////////////
	System.out.println("enroll C : " + String.valueOf(session.getAttribute("enrollment_create")));/////////////////////////
	System.out.println("enroll U : " + String.valueOf(session.getAttribute("enrollment_update")));/////////////////////////
	System.out.println("enroll R : " + String.valueOf(session.getAttribute("enrollment_read")));/////////////////////////
	System.out.println("enroll D : " + String.valueOf(session.getAttribute("enrollment_delete")));/////////////////////////
	
	System.out.println("enroll B : " + Boolean.valueOf(String.valueOf(session.getAttribute("enrollment_delete"))));/////////////////////////
	System.out.println("studentcreate B : " + Boolean.valueOf(String.valueOf(session.getAttribute("student_create"))));/////////////////////////
	
	System.out.println("student role : " + String.valueOf(session.getAttribute("student_role")));/////////////////////////
	System.out.println("curriculum role : " + String.valueOf(session.getAttribute("curriculum_role")));/////////////////////////	
	System.out.println("enroll role : " + String.valueOf(session.getAttribute("enrollment_role")));/////////////////////////
	
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	boolean student = Boolean.valueOf(String.valueOf(session.getAttribute("student_system")));
	boolean curriculum = Boolean.valueOf(String.valueOf(session.getAttribute("curriculum_system")));
	boolean enrollment = Boolean.valueOf(String.valueOf(session.getAttribute("enrollment_system")));
			
	System.out.println("student : " + student);///////////////////////////////
	System.out.println("curriculum : " + curriculum);/////////////////////////
	System.out.println("enrollment : " + enrollment);/////////////////////////
%>

	<div id="page-wrap">
			<div id="inside">
				<table border="0">
				<tr style="font-size:24px">
					<td width="600" height="100" style= "background-color: #273b80;border: 0px ;padding: 0px; 0px;" >
						<div id="header_banner-2"></div>
					</td>
					
					<td width="680" height="100" style= "background-color: #273b80;border: 0px;padding: 0px; 0px;" >
						<p align="right"><label><font size="4" color="#ffffff">username : <%=strUser %> &nbsp;&nbsp;</font></label></p>	
						<a href="logout.jsp"><p align="right"><label style="cursor: pointer;"><font size="3" color="#ffffff">log out &nbsp;</font></label></p></a>
					</td>
				</tr>
			</table>
						<div id="main-content-act">
							<br/><br/><br/><br/>
        					<center>
        						<div class="noborder">
        						<table border="0">
        							<tr height="200">
<%
  								if(student) {
%>     								
        								<td width="500" valign="center" style="text-align: center;" id="student_system" onclick="link_system(this.id)" >
        									<img src="image/student_icon.png" width="150" height="150">
        									<center><h1><a href="student_home.jsp">ระบบบริหารข้อมูลนักศึกษา</a></h1></center>
        									<br><br><br>
        								</td>
<%
  								}
  								else {
%>
										
<%
  								}

  								if(enrollment) {
%>     								
        								<td width="500" valign="center" style="text-align: center;" id="enroll_system" onclick="link_system(this.id)" >
        									<img src="image/enroll_icon.png" width="150" height="150">
											<center><h1><a href="enroll_home.jsp">ระบบบริหารข้อมูลลงทะเบียน</a></h1></center>
											<br><br><br>
										</td>	
<%
  								}
  								else {
%>
										
<%
  								}
  								
  								if(curriculum) {
%>     								
        								<td width="500" valign="center" style="text-align: center;" id="curriculum_system" onclick="link_system(this.id)" >
											<img src="image/curriculum_icon.png" width="150" height="150">
											<center><h1><a href="curriculum_home.jsp">ระบบจัดเก็บข้อมูลหลักสูตรการศึกษา</a></h1></center>
											<br><br><br>
										</td>	
<%
  								}
  								else {
%>
										
<%
  								}
%>          											
        																

										
										
									</tr>
								</table>
								</div>
					
							</center>
								
								<br/><br/><br/><br/>
								<br/><br/><br/><br/>
						</div>
					<div style="clear: both;"></div>
						<div id="footer"></div>
			</div>		
						<div style="clear: both;"></div>		
	</div>

</body>
</html>